package com.qn.example.mapper;

import com.qn.example.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

/**
 * @author 21276
 * @version 1.0
 * @date 2023/5/17 16:03
 */
public interface UserMapper {
    //根据手机号查找用户
    @Select("select * from user where phone=#{phone}")
    User findByPhone(String phone);

    //保存用户
    @Insert("insert into user value(null,#{name},#{phone},#{sex},#{idNumber},#{avatar},#{status})")
    //返回当前插入用户生成的id
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void save(User user);

    @Select("select * from user where id = #{userId}")
    User findUser(Long userId);
}
